package Base.Array;

import org.testng.annotations.Test;

import java.sql.SQLOutput;
import java.util.Scanner;

public class ArrayOperator {

    @Test
    public void work1(){
        int[] scores={0,0,1,2,3,5,4,5,2,8,7,6,9,5,4,8,3,1,0,2,4,8,7,9,5,2,1,2,3,9};

        int[] nums=new int[10];
        for(int x:scores){
            nums[x]++;
        }
        for(int i=0;i<10;i++){
            System.out.println((i+1)+"数量为："+nums[i]);
        }
    }

    @Test
    public void work2(){
        int[] scores={0,0,1,2,3,5,4,5,2,8,7,6,9,5,4,8,3,1,0,2,4,8,7,9,5,2,1,2,3,9};
        int oddn=0,eventn=0;
        for(int x : scores){
            if(x%2==1){
                oddn++;
            }else{
                eventn++;
            }
        }
        System.out.println("偶数为"+eventn);
        System.out.println("奇数为"+oddn);
    }
    @Test
    public void work3(){
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        //int n=12322;
        int firstBit=n%10;
        int secondBit=(n%100)/10;
        int fourthBit=(n%10000)/1000;
        int lastBit=(n%100000)/10000;
        if((firstBit==lastBit)&&(secondBit==fourthBit)){
            System.out.println("是回文");
        }else{
            System.out.println("不是回文");
        }
    }

    @Test
    public void work4(){
//        Scanner scanner = new Scanner(System.in);
//        String str = scanner.nextLine();
        String str="fads faso dh^&123324";
        String description[]={"英文字母","空格","数字","其他"};
        int numOfClass[]=new int[4];
        char chars[]=str.toCharArray();
        for(char c: chars){
            if((c>='a'&&c<='z')||(c>='A'&&c<='Z')){
                numOfClass[0]++;
            }else if(c>='0'&&c<='9'){
                numOfClass[2]++;
            }else if(c==' '){
                numOfClass[1]++;
            }else{
                numOfClass[3]++;
            }
        }
        for(int i=0;i<4;i++){
            System.out.println(description[i]+"数量为："+numOfClass[i]);
        }

    }
    @Test
    public void testlj(){
        char han1=0x6c49;
        System.out.println(han1);
        char han='汉';
        //System.out.format("%x",han);
        System.out.format("%x",(int)han);
        System.out.format("%x",(short)han);

    }
}
